package com.feihong.yw189.bluetooth.utils.util;

import android.os.SystemClock;
import android.text.TextUtils;

import com.sunnada.SYDReader.Commen;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Interface {

    public static String Version = "V1.0.01";
    ;
    public static String StrIp = "220.250.52.18";
    ;
    public static String StrPort = "23800";

    // 220.249.191.211

    // 20200

    public static byte[] MASTER_KEY = new byte[]{0x22, 0x08, 0x67, (byte) 0xC5,
            0x73, 0x34, 0x04, (byte) 0xE6};

    public static byte[] ECRYPT_KEY = new byte[]{0x31, 0x32, 0x33, 0x34,
            0x35, 0x36, 0x37, 0x38};
    public static int mCurDealType = 0;
    public static int mSetTime = 30;
    public static int sleeptime = 3000;
    public static long nTimer = SystemClock.uptimeMillis();
    public static long nTimerStart = 0;
    public static long nTimerEnd = 0;
    public static long nTimerTmp = 0;

    // 需要写入的卡数据
    public static String sSmsNum = "+8615806036081";
    public static String IMSI1 = "131466601332101";

    //厂家名称
    public static String[] mManuFacturer = {
            "三元达",
    };

    public static String mConnectUrl = "http://220.250.52.18:34003";
    public static String mMac = "";
    private static Calendar mCalendar = Calendar.getInstance();

    public static byte[] CreateBusiNo(String DeviceId) {
        byte[] mBusi_No = new byte[25];
        String currytime = new SimpleDateFormat("yyyyMMddHHmmssMM").format(mCalendar.getTime());
        mBusi_No[0] = 0x02;
        System.arraycopy(develop_to_8byte(DeviceId), 0, mBusi_No, 1, 8);
        System.arraycopy(currytime.getBytes(), 0, mBusi_No, 9, 14);
        return mBusi_No;

    }

    public static byte[] develop_to_8byte(String develop_id) {

        if (TextUtils.isEmpty(develop_id)) {
            return null;
        }

        if (develop_id.length() < 16) {
            StringBuffer sb = new StringBuffer();
            sb.append(develop_id);
            for (int i = 0; i < 16 - develop_id.length(); i++) {
                sb.append("0");
            }
            return Commen.str2bcdhfirst(sb.toString().getBytes());
        } else {
            return Commen.str2bcdhfirst(develop_id.substring(0, 16).getBytes());
        }
    }
}
